package itheima.a03polymorphismdemo3;

public class Test {
    public static void main(String[] args) {
        Person p = new Person("老王",25);
        // 向上转型
        Animal a = new Dog(2, "黑");
        //现在调用的是Dog类的方法
        p.keepPet(a,"骨头");
        Animal b=new Cat(3,"灰");
        //现在调用的是Cat类的方法
        p.keepPet(b,"鱼");
    }
}
